<?php

namespace App\Logics;


use App\Models\SiteInfo;

class SiteInfoLogic extends Logic
{

    // TODO 操作日志


    // 获取当前域名
    public function domain()
    {
        $opt     = $this->option();
        $domain  = $this->request()->server('HTTP_HOST');
        $isHttps = $this->request()->server('HTTPS');

        $domain = ($isHttps ? 'https://' : 'http://').$domain;

        return ['domain' => $domain];
    }

    // 当前cdn域名
    public function cdn()
    {
        $opt    = $this->option();
        $domain = $opt->domain('oss');

        return ['domain' => $domain];
    }

    // 内容
    public function content()
    {
        $opt = $this->option();
        $key = $opt->getData('key', null, 'trim');
        if(empty($key)){
            //return $this->_returnFail('请选择你要操作的数据！');
            return $this->_returnFail('please_select_the_data_you_wish_to_operate');
        }

        $model = new SiteInfo();
        $info  = $model->oneFind(['key' => $key]);
        if($info === false){
            return $this->_returnFail($model->getError());
        }

        return $info;
    }


}


